home *** CD-ROM | disk | FTP | other *** search
/ Mac Easy 2010 May / Mac Life Ubuntu.iso / casper / filesystem.squashfs / usr / share / doc / python-apt / html / _sources / apt_inst.txt next >
Encoding:
Text File  |  2009-03-30  |  2.8 KB  |  97 lines

  1. :mod:`apt_inst` - Working with local Debian packages
  2. ====================================================
  3. .. module:: apt_inst
  4.  
  5. The :mod:`apt_inst` extension provides access to functions for working with
  6. locally available Debian packages (.deb files) and tar files.
  7.  
  8.  
  9. Checking packages
  10. ------------------
  11. .. function:: arCheckMember(file, membername)
  12.  
  13.     Check if the member specified by the parameter *membername* exists in
  14.     the AR file referenced by the :class:`file` object *file*.
  15.  
  16.  
  17. Listing contents
  18. -----------------
  19. .. function:: debExtract(file, func, chunk)
  20.  
  21.     Call the function referenced by *func* for each member of the tar file
  22.     *chunk* which is contained in the AR file referenced by the file object
  23.     *file*.
  24.  
  25.     An example would be::
  26.  
  27.         debExtract(open("package.deb"), my_callback, "data.tar.gz")
  28.  
  29.     See :ref:`emulating-dpkg-contents` for a more detailed example.
  30.  
  31. .. function:: tarExtract(file,func,comp)
  32.  
  33.     Call the function *func* for each member of the tar file *file*.
  34.  
  35.     *Comp* is a string determining the compressor used. Possible options are
  36.     "lzma", "bzip2" and "gzip".
  37.  
  38.  
  39. Callback
  40. ^^^^^^^^^
  41. Both of these functions expect a callback with the signature
  42. ``(what, name, link, mode, uid, gid, size, mtime, major, minor)``.
  43.  
  44. The parameter *what* describes the type of the member. It can be 'FILE',
  45. 'DIR', or 'HARDLINK'.
  46.  
  47. The parameter *name* refers to the name of the member. In case of links,
  48. *link* refers to the target of the link.
  49.  
  50.  
  51. Extracting contents
  52. -------------------
  53.  
  54. .. function:: debExtractArchive(file, rootdir)
  55.  
  56.     Extract the archive referenced by the :class:`file` object *file*
  57.     into the directory specified by *rootdir*.
  58.  
  59.     See :ref:`emulating-dpkg-extract` for an example.
  60.  
  61.     .. warning::
  62.  
  63.         If the directory given by *rootdir* does not exist, the package is
  64.         extracted into the current directory.
  65.  
  66. .. function:: debExtractControl(file[, member='control'])
  67.  
  68.     Return the indicated file from the control tar. The default is 'control'.
  69.  
  70.     If you want to print the control file of a given package, you could do
  71.     something like::
  72.  
  73.         print debExtractControl(open("package.deb"))
  74.  
  75.     :return: The contents of the file, as :class:`str`.
  76.  
  77.  
  78. .. _emulating-dpkg-extract:
  79.  
  80. Example: Emulating :program:`dpkg` :option:`--extract`
  81. -------------------------------------------------------
  82. Here is a code snippet which emulates dpkg -x. It can be run as
  83. :program:`tool` :option:`pkg.deb` :option:`outdir`.
  84.  
  85. .. literalinclude:: examples/dpkg-extract.py
  86.  
  87.  
  88. .. _emulating-dpkg-contents:
  89.  
  90. Example: Emulating :program:`dpkg` :option:`--contents`
  91. -------------------------------------------------------
  92. .. literalinclude:: examples/dpkg-contents.py
  93.  
  94. Example: Emulating :program:`dpkg` :option:`--info`
  95. ----------------------------------------------------
  96. .. literalinclude:: examples/dpkg-info.py
  97.